<?php

/**
 * This is the model class for table "hazardous_area".
 *
 * The followings are the available columns in table 'hazardous_area':
 * @property integer $id
 * @property string $area
 * @property string $other
 * @property integer $separation_fire_rated
 * @property string $type_of_fire_protection_provided
 * @property integer $no_of_unit
 * @property integer $capacity
 * @property integer $accessible
 * @property string $fuel_used
 * @property string $where_stored
 * @property string $covered_by_bfp_permit
 * @property string $chimney_made_of
 * @property string $spark_arrester
 * @property string $smoke_hood
 * @property integer $presence_hazardous_material
 * @property integer $properly_stored_and_handled
 * @property string $storage_permit_covered_for_flammables_covered_by_bfp_permit
 * @property string $clearance_of_stock_from_ceiling
 * @property integer $inspection_id
 *
 * The followings are the available model relations:
 * @property Inspection $inspection
 * @property HazardousMaterial[] $hazardousMaterials
 */
class HazardousArea extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return HazardousArea the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'hazardous_area';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('inspection_id', 'required'),
			array('separation_fire_rated, no_of_unit, capacity, accessible, presence_hazardous_material, properly_stored_and_handled, inspection_id', 'numerical', 'integerOnly'=>true),
			array('area, other, type_of_fire_protection_provided, fuel_used, where_stored, covered_by_bfp_permit, chimney_made_of, spark_arrester, smoke_hood, storage_permit_covered_for_flammables_covered_by_bfp_permit, clearance_of_stock_from_ceiling', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, area, other, separation_fire_rated, type_of_fire_protection_provided, no_of_unit, capacity, accessible, fuel_used, where_stored, covered_by_bfp_permit, chimney_made_of, spark_arrester, smoke_hood, presence_hazardous_material, properly_stored_and_handled, storage_permit_covered_for_flammables_covered_by_bfp_permit, clearance_of_stock_from_ceiling, inspection_id', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'inspection' => array(self::BELONGS_TO, 'Inspection', 'inspection_id'),
			'hazardousMaterials' => array(self::HAS_MANY, 'HazardousMaterial', 'hazardous_area_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'area' => 'Area',
			'other' => 'Other',
			'separation_fire_rated' => 'Separation Fire Rated',
			'type_of_fire_protection_provided' => 'Type Of Fire Protection Provided',
			'no_of_unit' => 'No Of Unit',
			'capacity' => 'Capacity',
			'accessible' => 'Accessible',
			'fuel_used' => 'Fuel Used',
			'where_stored' => 'Where Stored',
			'covered_by_bfp_permit' => 'Covered By Bfp Permit',
			'chimney_made_of' => 'Chimney Made Of',
			'spark_arrester' => 'Spark Arrester',
			'smoke_hood' => 'Smoke Hood',
			'presence_hazardous_material' => 'Presence Hazardous Material',
			'properly_stored_and_handled' => 'Properly Stored And Handled',
			'storage_permit_covered_for_flammables_covered_by_bfp_permit' => 'Storage Permit Covered For Flammables Covered By Bfp Permit',
			'clearance_of_stock_from_ceiling' => 'Clearance Of Stock From Ceiling',
			'inspection_id' => 'Inspection',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('area',$this->area,true);
		$criteria->compare('other',$this->other,true);
		$criteria->compare('separation_fire_rated',$this->separation_fire_rated);
		$criteria->compare('type_of_fire_protection_provided',$this->type_of_fire_protection_provided,true);
		$criteria->compare('no_of_unit',$this->no_of_unit);
		$criteria->compare('capacity',$this->capacity);
		$criteria->compare('accessible',$this->accessible);
		$criteria->compare('fuel_used',$this->fuel_used,true);
		$criteria->compare('where_stored',$this->where_stored,true);
		$criteria->compare('covered_by_bfp_permit',$this->covered_by_bfp_permit,true);
		$criteria->compare('chimney_made_of',$this->chimney_made_of,true);
		$criteria->compare('spark_arrester',$this->spark_arrester,true);
		$criteria->compare('smoke_hood',$this->smoke_hood,true);
		$criteria->compare('presence_hazardous_material',$this->presence_hazardous_material);
		$criteria->compare('properly_stored_and_handled',$this->properly_stored_and_handled);
		$criteria->compare('storage_permit_covered_for_flammables_covered_by_bfp_permit',$this->storage_permit_covered_for_flammables_covered_by_bfp_permit,true);
		$criteria->compare('clearance_of_stock_from_ceiling',$this->clearance_of_stock_from_ceiling,true);
		$criteria->compare('inspection_id',$this->inspection_id);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}